/*
 * spi_conf.h
 *
 *  Created on: 12/mar/2014
 *      Author: Postazione Embedded
 */

#ifndef SPI_CONF_H_
#define SPI_CONF_H_

#include "stm32f4xx_spi.h"
#include "../gpio/gpio.h"

typedef struct
{
	char* spi_DeviceName;
	SPI_TypeDef* SPIx;
	GPIO_TypeDef* SPI_GPIO;
	uint8_t SCK_Pin_Source;
	uint8_t MISO_Pin_Source;
	uint8_t MOSI_Pin_Source;

	uint16_t SPI_Direction;
	uint16_t SPI_Mode;
	uint16_t SPI_DataSize;
	uint16_t SPI_CPOL;
	uint16_t SPI_CPHA;
	uint16_t SPI_NSS;
	uint16_t SPI_BaudRatePrescaler;
	uint16_t SPI_FirstBit;
	uint16_t SPI_CRCPolynomial;
} spi_Device;

void init_SPIx(spi_Device *);
void SPIx_write(spi_Device *, uint8_t);
uint8_t SPIx_read_write(spi_Device *, uint8_t);


#endif /* SPI_CONF_H_ */
